import pygame
from game_event_manager import GameEventManager
from gameworld import GW

class GameOver:
    def __init__(self):
        self.text = "GAME OVER"
        self.font = pygame.font.SysFont("微软雅黑", 40, "bold")
        self.surf = self.font.render(self.text, True, GW.COLOR_RED, GW.COLOR_WHITE)
        self.rect = self.surf.get_rect(
            center=(GW.BOARD_LEFT + 5 * GW.BLOCK_SIZE, 200)
        )
        self.visible = False

        GameEventManager.register_handler(GW.EVENT_GAME_OVER, self.show)

    def show(self, event=None):
        self.visible = True

    def draw(self, screen):
        if self.visible:
            screen.blit(self.surf, self.rect)
